import Vue from 'vue'
import Router from 'vue-router'
import AppIndex from '../components/home/AppIndex.vue'
import Login from '../components/Login.vue'
import Home from '../components/Home.vue'
import GoodsIndex from '../components/goods/GoodsIndex.vue'
import MallIndex from '../components/mall/MallIndex.vue'
import CartIndex from '../components/cart/CartIndex.vue'
import UserIndex from '../components/user/UserIndex.vue'

import AddGoods from '../components/mall/AddGoods.vue'
import MyMall from '../components/mall/MyMall.vue'
import MallOrder from '../components/mall/MallOrder.vue'
import MallMessage from '../components/mall/MallMessage.vue'
import Register from'../components/Registre.vue'
import GoodsDetail from'../components/goods/GoodsDetail.vue'
import Order from '../components/order/Order.vue'
import Admin from '../admin/AdminIndex.vue'

Vue.use(Router)

export default new Router({
  mode: 'history',
  routes: [
    // 下面都是固定的写法
    { path: '/', redirect: '/index' },
    {
      path:'/admin',
      name:'Admin',
      component:Admin
    },
    {
      path: '/login',
      name: 'Login',
      component: Login
    },
    {
      path:'/register',
      name:"Register",
      component:Register
    },
    {
      path: '/home',
      name: 'Home',
      component: Home,
      // home页面并不需要被访问
      redirect: '/index',
      children: [
        {
          path: '/index',
          name: 'AppIndex',
          component: AppIndex,
          meta: {
            requireAuth: true
          }
        },
        {
          path: '/goods',
          name: 'GoodsIndex',
          component: GoodsIndex,
          meta: {
            requireAuth: true
          }
        },
        {
          path:'/goodsDetail',
          name:'GoodsDetail',
          component:GoodsDetail,
          meta:{
             requireAuth: true
          }
        },
        {
          path:'/orderDetail',
          name:'OrderDetail',
          component:Order,
          meta:{
            requireAuth:true
          }
        },
        {
          path:'/mall',
          name:'MallIndex',
          component:MallIndex,
          meta:{
            requireAuth:true
          },
          redirect: '/myMall',
          children: [
            {
              path: '/myMall',
              name: 'MyMall',
              component: MyMall,
              meta: {
                requireAuth: true
              }
              },
              {
              path: '/addGoods',
              name: 'AddGoods',
              component: AddGoods,
              meta: {
                requireAuth: true
              }
              },
              {
              path: '/mallOredr',
              name: 'MallOrder',
              component: MallOrder,
              meta: {
                requireAuth: true
                }
              },
              {
              path: '/mallMessage',
              name: 'MallMessage',
              component: MallMessage,
              meta: {
                requireAuth: true
              }
              }
            ]
            },
            {
              path: '/goods',
              name: 'GoodsIndex',
              component: GoodsIndex,
              meta: {
                requireAuth: true
              }
            },
          {
          path:'/cart',
          name:'CartIndex',
          component:CartIndex,
          meta:{
            requireAuth:true
          }
        },
        {
          path:'/user',
          name:'UserIndex',
          component:UserIndex,
          meta:{
            requireAuth:true
          }
        }
      ]
    }
  ]
})
